<?php

namespace App\Controller\InsideService;

use App\Model\AdminApp;
use App\Model\AdminList;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\GetMapping;

#[Controller(prefix: '/sldnfInsideService/Admin')]
class AdminInside extends BaseInside {

    #[GetMapping(path: 'getAppInfo')]
    public function getAppInfo(): array {
        $appSecret = $this->request->query('app_secret', '');
        if ($appSecret) {
            $returnArr = AdminApp::query()->where('app_secret', $appSecret)->first();
            if ($returnArr) {
                $returnArr = $returnArr->toArray();
            } else {
                $returnArr = [];
            }
        } else {
            $returnArr = [];
        }

        return $this->buildSuccess([
            'list' => $returnArr
        ]);
    }

    #[GetMapping(path: 'getApiInfo')]
    public function getApiInfo(): array {
        $hash = $this->request->query('hash', '');
        if ($hash) {
            $returnArr = AdminList::query()->where('hash', $hash)->first();
            if ($returnArr) {
                $returnArr = $returnArr->toArray();
            } else {
                $returnArr = [];
            }
        } else {
            $returnArr = [];
        }

        return $this->buildSuccess([
            'list' => $returnArr
        ]);
    }
}